import wxBaaS from '../sdk-wechat.3.23.5';

// 定义文件上传函数
export async function uploadFileBySDK(filePath, fileType) {
  try {
    const MyFile = new wxBaaS.File();
    const fileParams = { filePath };
    const metaData = { categoryName: fileType };

    const response = await MyFile.upload(fileParams, metaData);
    const fileData = response.data; // 返回上传结果
    console.log('文件上传成功，文件URL:', fileData.path); // 打印上传文件的URL

    return fileData;
  } catch (error) {
    console.error('文件上传失败:', error);
    throw error;
  }
}
